<!DOCTYPE html>
<html>
<head>
    <title>FinalShell</title>
    <meta charset="UTF-8">
    <style>
        body {
            background-color: #111;
            color: #fff;
            font-family: Arial, sans-serif;
            text-align: center;
        }

        h1 {
            font-size: 28px;
            margin-top: 50px;
        }

        h2 {
            font-size: 20px;
            margin-top: 50px;
        }

        .container {
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            max-width: 500px;
            margin: 100px auto;
            padding: 20px;
            border: 1px solid #fff;
            border-radius: 10px;
            box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
        }

        label {
            display: block;
            font-size: 18px;
            margin-bottom: 10px;
        }

        input[type="text"] {
            width: 100%;
            padding: 10px;
            font-size: 16px;
            border: 1px solid #ccc;
            border-radius: 5px;
            margin-bottom: 20px;
        }

        input[type="submit"] {
            padding: 10px 20px;
            font-size: 16px;
            background-color: #007bff;
            color: #fff;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }

        .key-container {
            margin-top: 30px;
        }

        .key-container p {
            font-size: 18px;
            margin-bottom: 10px;
            display: flex;
            align-items: center;
        }

        .key-container p span {
            flex: 1;
        }

        .key-container p button {
            margin-left: 10px;
            padding: 5px 10px;
            font-size: 14px;
            background-color: #007bff;
            color: #fff;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }

        .instructions {
            margin-top: 30px;
            text-align: left;
        }
    </style>
    <script>
        function generateKey(hardwareId) {
            var proKey = transform(61305 + hardwareId + 8552);
            var pfKey = transform(2356 + hardwareId + 13593);
            return [proKey, pfKey];
        }

        function transform(str) {
            var md5 = hashMD5(str.toString());
            return md5.substring(8, 24);
        }

        function hashMD5(str) {
            return md5(str);
        }

        function md5(str) {
            // Implement your own MD5 hashing function here or use a library
            // This is a simplified example and should not be used in production
            return 'hashed_' + str;
        }

        function copyToClipboard(text) {
            var input = document.createElement('textarea');
            input.value = text;
            document.body.appendChild(input);
            input.select();
            document.execCommand('copy');
            document.body.removeChild(input);
            alert('已复制到剪贴板');
        }

        document.addEventListener('DOMContentLoaded', function () {
            var form = document.querySelector('form');
            form.addEventListener('submit', function (event) {
                event.preventDefault();
                var machineCode = document.getElementById('machineCode').value;
                var keys = generateKey(machineCode);
                var proKey = keys[0];
                var pfKey = keys[1];

                var keyContainer = document.querySelector('.key-container');
                keyContainer.innerHTML = `
                    <h2>密钥获取成功，恭喜您！</h2>
                    <p>
                        <span>专业版_KEY: ${proKey}</span>
                        <button onclick="copyToClipboard('${proKey}')">复制</button>
                    </p>
                    <p>
                        <span>个人版_KEY: ${pfKey}</span>
                        <button onclick="copyToClipboard('${pfKey}')">复制</button>
                    </p>
                `;

                var instructions = document.querySelector('.instructions');
                instructions.style.display = 'block';
            });
        });
    </script>
</head>
<body>
    <div class="container">
        <h1>FinalShell 离线激活密钥获取</h1>
        <form>
            <label for="machineCode">请输入FinalShell的离线机器码：</label>
            <input type="text" id="machineCode" required>
            <input type="submit" value="获取密钥">
        </form>

        <div class="key-container"></div>
        <div class="instructions" style="display: none;">
            <h2>使用说明：</h2>
            <p>1. 将获取到的密钥复制到 FinalShell 的相应位置。</p>
            <p>2. 确保离线机器码和密钥的对应关系正确。</p>
            <p>3. 完成上述步骤后，即可正常使用 FinalShell。</p>
            <p>4. 版本在3.9.4以上只能激活免费版。</p>
            <p>5. 请支持正版，页面提供的内容仅供试用。</p>
        </div>
    </div>
</body>
</html>
